package org.gwt.grin.rebind.commands;

import java.util.Formatter;

import org.gwt.grin.client.commands.Command;
import org.gwt.grin.rebind.SECommand;
import org.gwt.grin.rebind.ShowBuilder;

/**
 * Represents an individual command that is defined in-line in a show file.
 * 
 * @author Bill Foote (http://jovial.com)
 * @author ggeorg
 */
public class SEShowCommand extends SECommand {

	private final String originalSource;

	public SEShowCommand(String originalSource) {
		this.originalSource = originalSource;
	}

	@Override
	public String write(ShowBuilder builder) {
		String cn = Command.class.getName();
		Formatter formatter = new Formatter();
		formatter.format(
				"new %s(showInstance) { public void execute() { %s } }", cn,
				originalSource);
		return formatter.toString();
	}

	@Override
	protected String getClassName() {
		return Command.class.getName();
	}

}
